<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <div id="app">
      <h1>{{ new Date() | newTime}}</h1>
      <h1>人民币:{{money}}</h1>
      <h2>美元:{{newMoney}}</h2>
      <h3>汇率:{{t}}</h3>
      <button @click="t-=0.1">汇率变化</button>
    </div>
    <script src="./vue.js"></script>
    <script src="http://cdn.staticfile.org/moment.js/2.24.0/moment.js"></script>
    <script>
      new Vue({
        el: '#app',
        data: {
          money: 100,
          t: 7.1
        },
        computed: {
          newMoney () {
            return this.money / this.t
          }
        },
        watch: {
          t (newVal, oldVal) {
            if (newVal <= 6.9) {
              alert('提示：汇率已小于7')
            }
          }
        },
        filters: {
          newTime (str) {
            return moment(str).format('YYYY-MM-DD HH:mm:ss')
          }
        }
      })
    </script>
  </body>
</html>
